<%@page import="entity.*"%>
<%@page import="dao.*"%>
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>修改学员信息</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->
	<script type="text/javascript" src="js/jquery-3.4.1.min.js"></script>
  </head>
  
  <body>
    <%@include file="/checkLogin.jsp" %>
    <%
    	Long stuno=null;
    	stuno=Long.parseLong(request.getParameter("stuno"));
    	StudentDaoI sdao=new StudentDao();
    	Student student=sdao.get(stuno);
    	if(student==null){
    		out.print("<script>alert('没有找到学号为["+stuno+"]的学员');history.back();</script>");
    		return;
    	}
     %>
     <form action="doUpdateStu.jsp" method="post">
		<p>
		 学号：<input type="text" name="stuno" value="<%=student.getStuno()%>" readonly="readonly"/>
		</p>
		<p>
			学生姓名：<input type="text" name="sname" value="<%=student.getSname()%>"/>
		</p>
		<p>
			学生性别：
			<input type="radio"  name="sex" value="男"/>男
			<input type="radio"   name="sex" value="女"/>女
			<input type="radio"   name="sex" value="妖"/>妖
			<input type="radio"  name="sex" value="人妖"/>人妖
		</p>
		<p>
			联系方式：<input type="text" name="telephone" value="<%=student.getTelephone() %>" />
		</p>
		<p>
			学生Q Q：<input type="text" name="qq" value="<%=student.getQq() %>"/>
		</p>
		<p>
			学生微信：<input type="text" name="wechat" value="<%=student.getWechat() %>"/>
		</p>
		<p>
			学生年级： <select name="gradeid">
			 <%
			 	GradeDao gdao=new GradeDao();
			 	List<Grade> l=gdao.findALL();
			    for(Grade g:l){	
			  %>
			  <option value="<%=g.getId()%>"><%=g.getGname() %></option>
			   
			  <%-- <%
			    if(g.getId()==student.getGradeId()){
			   %>
			   <option value="<%=g.getId()%>" selected="selected"><%=g.getGname() %></option>
			   <%}else{ %>
			    <option value="<%=g.getId()%>"><%=g.getGname() %></option>
			    <%} %> --%>
			  <%} %>
			</select>
		</p>
		<p>
			入学日期：<input type="text" name="enterdate" value="<%=student.getEnterDate()%>"/>
		</p>
		<p>
			来自城市：<input type="text" name="fromcity" />
		</p>
		<p>
			出生日期：<input type="text" name="birthday" />
		</p>
		<p>
			登陆密码：<input type="text" name="pass" />
		</p>
		<p>
			家庭地址：<input type="text" name="address" />
		</p>
		<p><input type="submit" /></p>
	</form>
	<script type="text/javascript">
		$(function(){
		   $("select[name=gradeid]").val('<%=student.getGradeId()%>');	
		   $(":radio[name=sex][value=<%=student.getSex()%>]").prop("checked",true);
		});
	</script>
  </body>
</html>
